package com.yh.cms.mq;

import com.alibaba.fastjson.JSON;
import com.yh.cms.service.PageService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
public class ConsumerPostPage {
    @Autowired
    private PageService pageService;

    @RabbitListener(queues = "${yh.mq.queue}")
    public void postPage(String msg){
        // {pageId:5a795ac7dd573c04508f3a56}
        Map<String,String> map = JSON.parseObject(msg, Map.class);
        String pageId = map.get("pageId");

        //把html页面从gridFs上下载下来，存放到指定未知
        pageService.storeHtml2Path(pageId);

    }
}
